import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_fitness/component/checkable_card.dart';
import 'package:get/get.dart';

import 'add_record_logic.dart';

class AddRecordPage extends StatelessWidget {
  final AddRecordLogic logic = Get.put(AddRecordLogic());

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 20, top: 12, right: 20),
      child: ListView(
        children: [
          Text(
            "今天是\n${logic.dateTime.year}年${logic.dateTime.month}月${logic.dateTime.day}日",
            style: TextStyle(fontWeight: FontWeight.bold, fontSize: 35),
          ),
          Padding(
              padding: EdgeInsets.only(top: 20),
              child: Obx(() => CheckableCard(
                    isChecked: logic.isPray.value,
                    title: "是否做了祷告？",
                    onPress: () => logic.setIsPray(!logic.isPray.value),
                  ))),
          Padding(
              padding: EdgeInsets.only(top: 20),
              child: Obx(() => CheckableCard(
                    isChecked: logic.isRead.value,
                    title: "是否已经读经？",
                    onPress: () => logic.setIsRead(!logic.isRead.value),
                  ))),
          Padding(
            padding: EdgeInsets.only(top: 20),
            child: Obx(() => Container(
                  height: 100,
                  padding: EdgeInsets.only(left: 40, top: 14),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(14),
                      color: logic.weight.value < 0
                          ? Color(0xFFD3D3D3)
                          : Color(0xFF3711FE)),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text(
                        "今日体重",
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                      TextField(
                        decoration: InputDecoration(
                          hintText: "今天还未记录",
                          hintStyle: TextStyle(color: Colors.white),
                          border: InputBorder.none,
                        ),
                        keyboardType: TextInputType.number,
                        controller: logic.weightTextController,
                        style: TextStyle(color: Colors.white),
                      ),
                    ],
                  ),
                )),
          ),
          Padding(
            padding: EdgeInsets.only(top: 20),
            child: Obx(() => Container(
                  height: 100,
                  padding: EdgeInsets.only(left: 40, top: 14),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(14),
                      color: logic.step.value <= 0
                          ? Color(0xFFD3D3D3)
                          : Color(0xFF3711FE)),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      Text(
                        "今日步数",
                        style: TextStyle(color: Colors.white, fontSize: 18),
                      ),
                      TextField(
                        decoration: InputDecoration(
                          hintText: "今天还未记录",
                          hintStyle: TextStyle(color: Colors.white),
                          border: InputBorder.none,
                        ),
                        keyboardType: TextInputType.number,
                        controller: logic.stepTextController,
                        style: TextStyle(color: Colors.white),
                      ),
                    ],
                  ),
                )),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Container(
                margin: EdgeInsets.only(top: 20),
                width: 100,
                height: 50,
                child: ElevatedButton(
                  style: ButtonStyle(
                      backgroundColor: MaterialStateProperty.resolveWith<Color>(
                          (states) => Colors.black),
                      shape: MaterialStateProperty.resolveWith<OutlinedBorder>(
                          (states) => RoundedRectangleBorder(
                              borderRadius:
                                  BorderRadius.all(Radius.circular(30))))),
                  onPressed: logic.saveRecord,
                  child: Text(
                    "保存",
                    style: TextStyle(color: Colors.white, fontSize: 20),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
